Add red outline visual indicators for infeasible arms in ScatterPlot and ArmEffectsPlot#5026
Closed
sdaulton wants to merge 1 commit into
Closed
Add red outline visual indicators for infeasible arms in ScatterPlot and ArmEffectsPlot#5026sdaulton wants to merge 1 commit into
sdaulton wants to merge 1 commit into
Conversation
…and ArmEffectsPlot Summary: The ScatterPlot and ArmEffectsPlot analyses compute `p_feasible_mean` for each arm but only displayed it in the hover tooltip. Users had to hover over each point to discover constraint violations. This change adds a red outline around scatter points for arms that are likely infeasible (`p_feasible_mean < 0.1`), making constraint violations immediately visible. A "Likely Infeasible" legend entry is also added when any infeasible arms are present. In addition, `prepare_arm_data()` previously only included columns for the requested (plotted) metrics in its DataFrame. When a constraint metric differed from the plotted metrics, `_prepare_p_feasible()` couldn't find the constraint column, filled it with NaN, and all arms incorrectly appeared feasible. This fix ensures `_prepare_modeled_arm_data()` extracts all predicted metrics and `_prepare_raw_arm_data()` extracts all available data metrics, so constraint feasibility is computed correctly regardless of which metrics are plotted. Changes: - `plotly/utils.py`: Add `MINIMUM_P_FEASIBLE` threshold (renamed from `MINIMUM_CONTRAINT_VIOLATION_THRESHOLD`), `get_infeasibility_marker_line()` helper, and infeasibility constants. - `plotly/scatter.py`, `plotly/arm_effects.py`: Apply marker line to each trial's scatter points and add a "Likely Infeasible" legend entry. - `analysis/utils.py`: Fix `_prepare_modeled_arm_data` to extract all predicted metrics (not just plotted ones), `_prepare_raw_arm_data` to extract all available data metrics, `_get_status_quo_df` to handle extra columns in NaN checks and status quo column selection. Extra columns are stripped before returning from `prepare_arm_data()` to preserve the API contract. - Tests: Add `TestScatterPlotInfeasibility` and `TestArmEffectsPlotInfeasibility` classes covering red outlines on infeasible arms, legend presence/absence, and the case where the constraint metric differs from the plotted metrics. Reviewed By: mpolson64 Differential Revision: D94783502
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5026 +/- ##
========================================
Coverage 96.83% 96.84%
========================================
Files 605 605
Lines 65235 65338 +103
========================================
+ Hits 63173 63274 +101
- Misses 2062 2064 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request has been merged in ad3e606. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The ScatterPlot and ArmEffectsPlot analyses compute
p_feasible_meanfor each arm but only displayed it in the hover tooltip. Users had to hover over each point to discover constraint violations.This change adds a red outline around scatter points for arms that are likely infeasible (
p_feasible_mean < 0.1), making constraint violations immediately visible. A "Likely Infeasible" legend entry is also added when any infeasible arms are present.In addition,
prepare_arm_data()previously only included columns for the requested (plotted) metrics in its DataFrame. When a constraint metric differed from the plotted metrics,_prepare_p_feasible()couldn't find the constraint column, filled it with NaN, and all arms incorrectly appeared feasible. This fix ensures_prepare_modeled_arm_data()extracts all predicted metrics and_prepare_raw_arm_data()extracts all available data metrics, so constraint feasibility is computed correctly regardless of which metrics are plotted.Changes:
plotly/utils.py: AddMINIMUM_P_FEASIBLEthreshold (renamed fromMINIMUM_CONTRAINT_VIOLATION_THRESHOLD),get_infeasibility_marker_line()helper, and infeasibility constants.plotly/scatter.py,plotly/arm_effects.py: Apply marker line to each trial's scatter points and add a "Likely Infeasible" legend entry.analysis/utils.py: Fix_prepare_modeled_arm_datato extract all predicted metrics (not just plotted ones),_prepare_raw_arm_datato extract all available data metrics,_get_status_quo_dfto handle extra columns in NaN checks and status quo column selection. Extra columns are stripped before returning fromprepare_arm_data()to preserve the API contract.TestScatterPlotInfeasibilityandTestArmEffectsPlotInfeasibilityclasses covering red outlines on infeasible arms, legend presence/absence, and the case where the constraint metric differs from the plotted metrics.Reviewed By: mpolson64
Differential Revision: D94783502